﻿#include "DiagPrecond.hpp"

#ifdef TIMERS
#include "utilityTimers.hpp"
#endif

template <typename Cmpt>
UNAP::DiagPrecond<Cmpt>::DiagPrecond(const Matrix<Cmpt> &A)
    : Preconditioner<Cmpt>(A.getCommunicator()),
      rD_(A.size(), A.getCommunicator()) {
  reciprocal(rD_, A.diag());
}

template <typename Cmpt>
void UNAP::DiagPrecond<Cmpt>::precondition(Vector<Cmpt> &w,
                                           const Vector<Cmpt> &r) const {
  pointwiseMul(w, rD_, r);
}

template class UNAP::DiagPrecond<scalar>;
